package com.ubi.core.database.pagination;

import java.io.Serializable;
import java.util.List;


public class PageSortingSearchResultDto<T> implements Serializable {
    //总记录数
    private int total;

    // 数据
    private List<T> dataList;

    public PageSortingSearchResultDto(int total, List<T> dataList) {
        this.total = total;
        this.dataList = dataList;
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public List<T> getDataList() {
        return dataList;
    }

    public void setDataList(List<T> dataList) {
        this.dataList = dataList;
    }

    //返回总页数
    public int getTotalPage(int pageSize) {
        int totalPage = 0;
        if (total == 0 || pageSize == 0) {
            totalPage = 0;
        } else if (total < pageSize) {
            totalPage = 1;
        } else if (total % pageSize == 0) {
            totalPage = total / pageSize;
        } else if (total % pageSize != 0) {
            totalPage = total / pageSize + 1;
        }
        return totalPage;
    }

}
